package com.ateam.dao.impl;

import java.util.List;

import org.mybatis.spring.SqlSessionTemplate;

import com.ateam.dao.ProjectsDao;
import com.ateam.pojo.Projects;

/** 
* @author WuYuan
* 
*/
public class ProjectsDaoImpl implements ProjectsDao {
	private SqlSessionTemplate sqlSessionTemplate;
	
	public SqlSessionTemplate getSqlSessionTemplate() {
		return sqlSessionTemplate;
	}

	public void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) {
		this.sqlSessionTemplate = sqlSessionTemplate;
	}
	
	@Override
	public int addProject(Projects project) throws Exception {
		return sqlSessionTemplate.insert("addProject",project);
	}

	@Override
	public int addProjectLeader(int userid, int projectid) throws Exception {
		Object [] objects =new Object[]{userid,projectid};
		return sqlSessionTemplate.insert("addProjectLeader",objects);
	}

	@Override
	public List<Projects> getProjectsByUser(int userid) throws Exception {
		return sqlSessionTemplate.selectList("getProjectsByUser", userid);
	}

	@Override
	public Projects getProjectByProjectid(int projectid) throws Exception {
		return sqlSessionTemplate.selectOne("getProjectByProjectid", projectid);
	}

	@Override
	public int updateProjectComplete(int projectid) throws Exception {
		return sqlSessionTemplate.update("updateProjectComplete", projectid);
	}

}
